﻿<local:AnimatedRotatePhoneApplicationPage
    x:Class="Google_Plus.Pages.StreamPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:myControls="clr-namespace:Google_Plus.Controls"
    xmlns:local="clr-namespace:Google_Plus.Types"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:WPE="clr-namespace:WPExtensions;assembly=WPExtensions"
    xmlns:c4f="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    Loaded="Page_Loaded">

    <Grid>
        <c4f:MemoryCounter VerticalAlignment="Top" Height="100"/>
        <controls:Pivot Title="Google+"
                        SelectionChanged="Pivot_SelectionChanged">
            <controls:PivotItem Header="Stream" Margin="0 -10 0 0">
                <!--
                <ScrollViewer>
                    <StackPanel>
                        <toolkit:ListPicker
                            x:Name="CircleSelector"
                            Header="circle"
                            FullModeHeader="circle" 
                            SelectionChanged="ListPicker_SelectionChanged"
                            ExpansionMode="FullScreenOnly"
                            ItemsSource="{Binding Circles}">
                            <toolkit:ListPicker.FullModeItemTemplate>
                                <DataTemplate>
                                    <toolkit:ListPickerItem Content="{Binding Key}"/>
                                </DataTemplate>
                            </toolkit:ListPicker.FullModeItemTemplate>
                            <toolkit:ListPicker.ItemTemplate>
                                <DataTemplate>
                                    <toolkit:ListPickerItem Content="{Binding Key}"/>
                                </DataTemplate>
                            </toolkit:ListPicker.ItemTemplate>
                        </toolkit:ListPicker>
                        <ItemsControl Name="PostsList" CacheMode="BitmapCache">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <local:PostView 
                                        Tap="Button_Tap" 
                                        Tag="{Binding ID}">
                                    </local:PostView>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </StackPanel>
                </ScrollViewer>
                -->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="120"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <toolkit:ListPicker
                            x:Name="CircleSelector"
                            Header="circle"
                            FullModeHeader="circle" 
                            SelectionChanged="ListPicker_SelectionChanged"
                            ExpansionMode="FullScreenOnly"
                            ItemsSource="{Binding Circles}">
                        <toolkit:ListPicker.FullModeItemTemplate>
                            <DataTemplate>
                                <toolkit:ListPickerItem 
                                    Content="{Binding Key}"
                                    FontSize="{StaticResource PhoneFontSizeMedium}"/>
                            </DataTemplate>
                        </toolkit:ListPicker.FullModeItemTemplate>
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Key}"/>
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                    </toolkit:ListPicker>
                    <ListBox Name="PostsList" CacheMode="BitmapCache" Grid.Row="1">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <!--
                                <local:PostView 
                                        Tap="Button_Tap" 
                                        Tag="{Binding ID}">
                                </local:PostView>
                                -->
                                <myControls:PostView
                                    Tap="Button_Tap" 
                                    Tag="{Binding ID}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>
                </Grid>
            </controls:PivotItem>

            <controls:PivotItem Header="Circles" Margin="0 -10 0 0">
                <ListBox x:Name="InYourCircles">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <HyperlinkButton Margin="3" NavigateUri="{Binding StringFormat=//Pages/ProfilePage.xaml?uid\=\{0\}, Path=Key}">
                                <HyperlinkButton.Template>
                                    <ControlTemplate>
                                        <Image Height="64" Width="64" Source="{Binding Value}"/>
                                    </ControlTemplate>
                                </HyperlinkButton.Template>
                            </HyperlinkButton>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>

        <WPE:AdvancedApplicationBar x:Name="appbar" IsVisible="False">
            <WPE:AdvancedApplicationBarIconButton IconUri="/Images/appbar.add.rest.png" Text="New post" x:Name="appbarNewPost" Click="appbarNewPost_Click" />
            <WPE:AdvancedApplicationBarIconButton IconUri="/Images/appbar.refresh.rest.png" Text="Refresh" x:Name="appbarRefresh" Click="appbarRefresh_Click"/>
            <WPE:AdvancedApplicationBarIconButton IconUri="/Images/appbar.status.rest.png" Text="Profile" x:Name="appbarbtnProfile" Click="appbarProfile_Click"/>
            <WPE:AdvancedApplicationBarIconButton IconUri="/Images/simon.notification.0.png" Text="Notification" x:Name="appbarNotification" Click="appbarNotification_Click"/>
            <WPE:AdvancedApplicationBarMenuItem Text="Sign out" x:Name="appbarLogout" Click="appbarLogout_Click"/>
        </WPE:AdvancedApplicationBar>
    </Grid>
</local:AnimatedRotatePhoneApplicationPage>